# Maintainer: David Runge <dvzrv@archlinux.org>

_name=rjsmin
pkgname=python-rjsmin
pkgver=1.2.1
pkgrel=2
pkgdesc="Fast javascript minifier for Python"
arch=(loong64 x86_64)
url="https://github.com/ndparker/rjsmin"
license=(Apache)
depends=(python)
makedepends=(python-build python-installer python-setuptools python-wheel)
checkdepends=(python-pytest)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha512sums=('14920b368c287f53b3d5b5f41c43f8cdcd4d5aff9ec824c33870a62fb0641a1850963a2c5fa0bab777ce094090c507f6dbe11ca3090cc6861c7c6f5d7e30fa96')
b2sums=('2ed9275edd15b66a4fd5cfb13f916506ed0686a32ac15cc7763e67a8af6f4d6d93b037fb0cbf0e87858af3dcda71c51e1fdf6531e828a47ccb0ad51896c20f93')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  # install to temporary location, as importlib is used
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH"
  pytest -vv
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 {docs/{CHANGES,DESCRIPTION},README.md} -t "$pkgdir/usr/share/doc/$pkgname/"
}
